package com.nuanshui.heatedloan.order.enums;

import com.google.common.collect.Maps;

import java.util.Map;

/**
 * 其实这个类是对应着  @see com.nuanshui.heatedloan.appointment.constant.AppointmentOrderTypeConstant
 * @Author: Gonzo
 * @Date 2017/3/1514:29
 * @since 1.4.0
 */
public enum OrderOptionType {
    NONE(0),
    MUSEUM_APPOINTMENT_ORDER(100), //展馆预约
    MUSEUM_ACTIVITY_APPOINTMENT_ORDER(101),//活动预约
    MUSEUM_MOVIE_APPOINTMENT_ORDER(102),//电影免费
    MUSEUM_APPOINTMENT_NOTFREE_ORDER(200),//展馆收费
    MUSEUM_ACTIVITY_NOTFREE_APPOINTMENT_ORDER(201),//活动收费预约
    MUSEUM_MOVIE_APPOINTMENT_NOTFREE_ORDER(202),//电影收费
    ;

    private Integer type;
    private final static Map<Integer, OrderOptionType> cache = Maps.newHashMap();

    private OrderOptionType(Integer type){
        this.type = type;
    }


    public static OrderOptionType getOrderOptionType(Integer orderType){

        if(cache.isEmpty()){
            synchronized (OrderOptionType.class){
                if(cache.isEmpty()){ //这里再判断一次，是因为如果有两个线程同时进来的话，外面都卡再这个锁外面，那么一个线程执行完之后，其他的线程还是会进来的
                    OrderOptionType typts[] = OrderOptionType.values();
                    for(OrderOptionType type : typts){
                        cache.put(type.getType(), type);
                    }
                }
            }
        }

        return cache.get(orderType);

    }

    public Integer getType() {
        return type;
    }

    public void setType(Integer type) {
        this.type = type;
    }


}
